import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;

public class Solution {
    public static void main(String[] args) {

    }
    public int[][] reconstructQueue(int[][] people) {
//        排序
        Arrays.sort(people, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                if (o1[0]==o2[0]){
                    return o1[1]-o2[1];
                }
                else  return o2[0] - o1[0];
            }
        });
        List<int[]> res = new LinkedList<>();
        for (int[] person : people) {
            res.add(person[1],person);
        }
        return res.toArray(new int[res.size()][2]);
    }
}